// keep-jsdocs.js
const result = await Bun.build({
  outdir: './out',
  entrypoints: ['./src/aio.ts'],
  naming: 'aio.js',
  target: 'browser',
  minify: false,
  plugins: [
    {
      name: "aio",
      setup(build) {
        build.onLoad(
          { filter: /\.(ts)$/ },
          async ({ path }) => {
            let text = await Bun.file(path).text();
            let contents = text.replaceAll('//', '//!');

            return {
              contents,
              loader: 'ts',
            }
          }
        );
      },
    },
  ],
})

const output = result?.outputs?.[0]
const txt = await output?.text()
const contents = txt.replaceAll('//!', '//')

await Bun.write(output?.path, contents);

